package com.example.mansystem.service;


import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

/**
 * @author fjl
 */
@Slf4j
@Component
public class SelfUserDetailsServiceImpl implements UserDetailsService {

    private final SecurityUserService userService;

    public SelfUserDetailsServiceImpl(SecurityUserService userService) {
        this.userService = userService;
    }

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        return userService.findOneUserByName(username);
    }
}